<?php
class relasi_kakak_pembina extends MY_Controller{
    var $data;
    function relasi_kakak_pembina(){
        parent::MY_Controller();
        $this->data['title'] = 'Relasi Kakak Pembina';
        $this->load->model('m_relasi_kakak_pembina');
    }
    function index(){
        $this->data['content'] = 'relasi_kakak_pembina/v_relasi_kakak_pembina';
        $this->data['listRelasiKakakPembina'] = $this->m_relasi_kakak_pembina->getRelasiKakakPembinaAdikAsuh();
        
        $this->render($this->data);
    }
    function add_relasi_kakak_pembina_form(){
        $this->data['content'] = 'relasi_kakak_pembina/v_relasi_kakak_pembina';
        $this->data['subLink'] = 'relasi_kakak_pembina/add_relasi_kakak_pembina_proses';
        $this->data['formTitle'] = 'Form tambah data relasi kakak pembina';
        $this->data['formView'] = 'relasi_kakak_pembina/add_relasi_kakak_pembina_form';
        $this->data['listRelasiKakakPembina'] = $this->m_relasi_kakak_pembina->getRelasiKakakPembinaAdikAsuh();
        
        $this->render($this->data);
    }
    function edit_relasi_kakak_pembina_form($id){
        $this->data['content'] = 'relasi_kakak_pembina/v_relasi_kakak_pembina';
        $this->data['subLink'] = 'relasi_kakak_pembina/edit_relasi_kakak_pembina_proses';
        $this->data['formTitle'] = 'Form edit data relasi kakak pembina';
        $this->data['formView'] = 'relasi_kakak_pembina/edit_relasi_kakak_pembina_form';
        $this->data['dataInput'] = $this->m_relasi_kakak_pembina->getRelasiKakakPembina(NULL,$id);
        $this->data['listRelasiKakakPembina'] = $this->m_relasi_kakak_pembina->getRelasiKakakPembinaAdikAsuh();
        
        $this->render($this->data);
    }
    function add_relasi_kakak_pembina_proses(){
        $id_adik_asuh = $this->input->post('id_adik_asuh');
        $id_kakak_pembina = $this->input->post('id_kakak_pembina');
        
        $data = array('id_adik_asuh' => $id_adik_asuh,'id_member' => $id_kakak_pembina);
        $insert = $this->m_relasi_kakak_pembina->addRelasiKakakPembina($data);
        if($insert == TRUE){
            $this->session->set_flashdata("message",1);
        }else{
            $this->session->set_flashdata("message",2);
        }
        
        redirect("relasi_kakak_pembina");
    }
    function edit_relasi_kakak_pembina_proses(){
        $id = $this->input->post('id_relasi');
        $id_adik_asuh = $this->input->post('id_adik_asuh');
        $id_kakak_pembina = $this->input->post('id_kakak_pembina');
        
        $data = array('id' => $id,'id_adik_asuh' => $id_adik_asuh,'id_member' => $id_kakak_pembina);
        $update = $this->m_relasi_kakak_pembina->editRelasiKakakPembina($data);
        if($update == TRUE){
            $this->session->set_flashdata("message",1);
        }else{
            $this->session->set_flashdata("message",2);
        }
        
        redirect("relasi_kakak_pembina");
    }
    function delete_relasi_kakak_pembina($id){
        $delete = $this->m_relasi_kakak_pembina->deleteRelasiKakakPembina($id);
        if($delete == TRUE){
            $this->session->set_flashdata("message",1);
        }else{
            $this->session->set_flashdata("message",2);
        }
        
        redirect("relasi_kakak_pembina");
    }
}
?>
